#include "ui_point.h"
#include "ui_error.h"


namespace UI
{

UI_Point::UI_Point(const std::string str){
	std::vector<std::string> RectStrings = stdex::DetokenizeString(str, ",");
	if (RectStrings.size() == 2)
	{
		m_XPos = stdex::safe_static_cast<int>(stdex::atoi(RectStrings[0]));
		m_YPos = stdex::safe_static_cast<int>(stdex::atoi(RectStrings[1]));
	}
	else
	{
		throw(UI_Ex_App("KTV_Point::KTV_Point : Unable to instantiate KTV_Point from string."));
	}
}

// add the points
UI_Point UI_Point::operator+(const UI_Point& p) const
{
	UI_Point result;
	result.SetX(m_XPos + p.XPos());
	result.SetY(m_YPos + p.YPos());

	return result;
}


// subtract the points
UI_Point UI_Point::operator-(const UI_Point& p) const
{
	UI_Point result;
	result.SetX(m_XPos - p.XPos());
	result.SetY(m_YPos - p.YPos());

	return result;
}


// assignment operator
UI_Point UI_Point::operator=(const UI_Point& p)
{
	m_XPos = p.XPos();
	m_YPos = p.YPos();

	return *this;
}

}

